package cn.com.basic.framework.web.error;

import cn.com.basic.framework.exception.enums.errors.SystemError;

/**
 * @author cuixk
 * @Description: 系统异常
 */

public class BizException extends RuntimeException {

    private String errorCode = SystemError.SYSTEM_EXECUTE_ERROR.getKey();

    public BizException() {
    }

    public BizException(String message) {
        super(message);
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
    }

    public BizException(SystemError systemError) {
        super(systemError.getValue());
        this.errorCode = systemError.getKey();
    }

    public BizException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
    }

    public String getErrorCode() {
        return errorCode;
    }


    public static BizException newException(SystemError systemError) {
        return new BizException(systemError);
    }

    public static BizException newException(SystemError systemError, String message) {
        return new BizException(systemError.getKey(), message);
    }

}

